cmake_minimum_required(VERSION 3.0.2)
project(tello_control)
add_compile_options(-std=c++11)
## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

# Find X11
MESSAGE ( STATUS "Searching for X11..." )
FIND_PACKAGE ( X11 REQUIRED )
IF ( X11_FOUND )
INCLUDE_DIRECTORIES ( ${X11_INCLUDE_DIR} )
 LINK_LIBRARIES ( ${X11_LIBRARIES} )
 MESSAGE ( STATUS " X11_INCLUDE_DIR: " ${X11_INCLUDE_DIR} )
  MESSAGE ( STATUS " X11_LIBRARIES: " ${X11_LIBRARIES} )
ENDIF ( X11_FOUND )

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS  
  roscpp
  geometry_msgs
  nav_msgs
  sensor_msgs
  std_msgs
  tf
  tf2_ros
  tf2_eigen
  uav_drone_msgs
  message_generation
  eigen_conversions

  rosconsole
  roscpp_serialization
  actionlib
  cv_bridge
  image_transport
  rostime
  
)
## eigen_conversions 是用来 实现geometry_msgs 和 eigen 类型的转换
## System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS
    system
    thread
    date_time
)

find_package(OpenCV REQUIRED)
find_package(Eigen3 REQUIRED)

# Enable OPENCV in darknet

################################################
## Declare ROS messages, services and actions ##
################################################
add_message_files(
  FILES
  Person.msg
)
## Generate added messages and services with any dependencies listed here
generate_messages(
  DEPENDENCIES
  geometry_msgs
  nav_msgs
  sensor_msgs
  std_msgs
)

catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS 
  roscpp 
  rospy
  geometry_msgs 
  nav_msgs 
  sensor_msgs 
  std_msgs
  message_runtime
)


###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${Boost_INUCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
  ${EIGEN3_INCLUDE_DIR}
  ../common/include
)


###############################
##      声明可执行cpp文件     ##
###############################

add_library(KeyboardEvent src/lib/KeyboardEvent.cpp)

###### Main File ##########



###### Utilities File ##########

add_executable(sylu_terminal_base src/utilities/sylu_terminal_base.cpp)
add_dependencies(sylu_terminal_base tello_control_gencpp)
target_link_libraries(sylu_terminal_base ${catkin_LIBRARIES})
target_link_libraries(sylu_terminal_base KeyboardEvent)

add_executable(tello_terminal src/tello_terminal.cpp)
add_dependencies(tello_terminal tello_control_gencpp)
target_link_libraries(tello_terminal ${catkin_LIBRARIES})
target_link_libraries(tello_terminal KeyboardEvent)

add_executable(tello_pos_estimator src/tello_pos_estimator.cpp)
add_dependencies(tello_pos_estimator tello_control_gencpp)
target_link_libraries(tello_pos_estimator ${catkin_LIBRARIES})

add_executable(tello_sender src/tello_sender.cpp)
add_dependencies(tello_sender tello_control_gencpp)
target_link_libraries(tello_sender ${catkin_LIBRARIES})

add_executable(aruco_det src/object_detection/aruco_det.cpp)
target_link_libraries(aruco_det ${catkin_LIBRARIES} ${Boost_LIBRARIES} ${OpenCV_LIBS} yaml-cpp)

add_executable(track_aruco src/mission/track_aruco.cpp)
add_dependencies(track_aruco tello_control_gencpp)
target_link_libraries(track_aruco ${catkin_LIBRARIES})
## Nodes
add_executable(web_cam src/object_detection/web_cam.cpp)
target_link_libraries(web_cam ${catkin_LIBRARIES} ${Boost_LIBRARIES} ${OpenCV_LIBS})

## Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
  FILES_MATCHING PATTERN "*.h"
)

## Mark other files for installation (e.g. launch and bag files, etc.)
install(DIRECTORY launch/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
)
